package com.aaa.service.impl;

import com.aaa.dao.TypeMapper;
import com.aaa.entity.Type;
import com.aaa.service.TypeServiceDao;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class TypeService extends ServiceImpl<TypeMapper, Type> implements TypeServiceDao {

    @Resource
    TypeMapper typeMapper;

    @Override
    public PageInfo<Type> pages(Integer pageNum, Integer pageSize, Type type) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.like("name",type.getName());
        List<Type> list = typeMapper.selectList(queryWrapper);
        PageInfo<Type> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
